/*
 * file_list.h
 *
 *  Created on: 2011-6-16
 *      Author: JustinLee
 */

#ifndef FILE_LIST_H_
#define FILE_LIST_H_

#ifdef __cplusplus
extern "C"{
#endif

#define MAX_PATH_LEN 1024
#define MAX_FILE_NAME_LEN 512
#define MAX_FILE_NUM 2048

#ifndef bool
#define bool char
#endif

#ifndef true
#define true 1
#endif

#ifndef false
#define false 0
#endif

typedef enum e_FILE_TYPE{
    F_T_OTHER = 0,
    F_T_VIDEO,
    F_T_AUDIO,
    F_T_PICTURE,
    F_T_NUM,
}FILE_TYPE;
    
typedef enum e_MOVIE_CONTAINER{
	M_C_T_UNKNOWN = 0,
	M_C_T_MP4,
	M_C_T_FLV,
	M_C_T_MPEG,
	M_C_T_AVI,
	M_C_T_MOV,
	M_C_T_WMV,
	M_C_T_RMVB,
	M_C_T_RM,
	M_C_T_ASF,
	M_C_T_MKV,
	M_C_T_3GP,
	M_C_T_TS,
}MOVIE_CONTAINER_TYPE;

typedef enum e_VIDEO_ENCODER{
	V_E_T_UNKNOWN = 0,
	V_E_T_H264,
	V_E_T_H263,
	V_E_T_H261,
	V_E_T_MPEG,
	V_E_T_MPEG2,
	V_E_T_MPEG4,
	V_E_T_RV10,
	V_E_T_RV20,
	V_E_T_RV30,
	V_E_T_RV40,
	V_E_T_VP6,
	V_E_T_XVID,
	V_E_T_VC1,
	V_E_T_WMV1,
	V_E_T_WMV2,
	V_E_T_JPEG,
	V_E_T_BMP,
}VIDEO_ENCODER_TYPE;

typedef enum e_AUDIO_ENCODER{
	A_E_T_UNKNOWN = 0,
	A_E_T_AAC,
	A_E_T_FLAC,
	A_E_T_MP3,
	A_E_T_MPEG,
	A_E_T_PCM,
	A_E_T_MPEG4,
	A_E_T_COOK,
	A_E_T_WMA1,
	A_E_T_WMA2,
	A_E_T_WMAPRO,
	A_E_T_AMR,
	A_E_T_AC3,
	A_E_T_APE,
}AUDIO_ENCODER_TYPE;

typedef enum e_SCRIPT_ENCODER{
	S_E_T_UNKNOWN = 0,
	S_E_T_SUB,
}SCRIPT_ENCODER_TYPE;

typedef struct tagMOVIE_FILE_INFO {
	MOVIE_CONTAINER_TYPE container_type;
	long long time_len_in_microsec;
	long time_len_hour;
	long time_len_min;
	long time_len_sec;
	long width;
	long height;
	long sample_rate;
	long channels_num;
	bool has_video;
	VIDEO_ENCODER_TYPE video_encoder_type;
	bool has_audio;
	AUDIO_ENCODER_TYPE audio_encoder_type;
	bool has_script;
	SCRIPT_ENCODER_TYPE script_encoder_type;
}MOVIE_FILE_INFO;

typedef struct tagMODIFIED_TIME{
	long year;
	long month;
	long day;
	long hour;
	long min;
	long sec;
}MODIFIED_TIME;

typedef struct tagFILE_INFO {
	char file_name[MAX_FILE_NAME_LEN];
	long long file_size;
	MODIFIED_TIME modified_time;
	bool has_resolved_movie_file_info;
	MOVIE_FILE_INFO movie_info;
    bool is_folder;
}FILE_INFO;

typedef struct tagFILE_INFO_LIST{
	char path[MAX_PATH_LEN];
	FILE_INFO array[MAX_FILE_NUM];
	int count;
	struct tagFILE_INFO_LIST* next;
}FILE_INFO_LIST;

FILE_INFO_LIST* create_file_list(char* path);
void update_file_list(FILE_INFO_LIST* list);
void close_file_list(FILE_INFO_LIST* list);
    
FILE_TYPE get_file_type_by_file_name(char* file_name);
    
int create_copy_file(const char *source, const char *target);
    
#ifdef __cplusplus
}
#endif

#endif /* FILE_LIST_H_ */
